﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using Newtonsoft.Json;
using System.Data.Entity.Infrastructure;
using _24_Hour_Blogger.Models;
using _24_Hour_Blogger.Models.Content;
using _24_Hour_Blogger.Library;

namespace _24_Hour_Blogger.ViewModels.Content
{
    public partial class UserViewModel : ViewModelBase<User>
    {

        public UserViewModel()
        {
            this.Entity = new User();
        }

        DbContext dataContext = null;
        DbSet<User> entitiesCollection = null;
        User entityClass = null;
        public UserViewModel(DbContext dataContext, DbSet<User> entitiesCollection, User entityClass)
        //: base(dbContext, entitiesCollection, entityClass)
        {

            this.dataContext = dataContext;
            this.entitiesCollection = entitiesCollection;
            this.entityClass = entityClass;
            if (this.entityClass == null)
            {
                this.entityClass = new User();
            }
            this.Entity = this.entityClass;
        }

        public override Int32 Id
        {
            get
            {
                return Entity.UserId;
            }
            set
            {

                Entity.UserId = value;


            }
        }

        public Int32 UserId
        {
            get
            {
                return Entity.UserId;
            }
            set
            {
                if (value > 0)

                    if (Entity.UserId != value)
                    {
                        Entity.UserId = value;
                        this.IsDirty = true;
                    }
            }
        }

        public String Email
        {
            get
            {
                return Entity.Email;
            }
            set
            {
                if (Entity.Email != value)
                {
                    Entity.Email = value;
                    this.IsDirty = true;
                }
            }
        }

        public String FirstName
        {
            get
            {
                return Entity.FirstName;
            }
            set
            {
                if (Entity.FirstName != value)
                {
                    Entity.FirstName = value;
                    this.IsDirty = true;
                }
            }
        }

        public String LastName
        {
            get
            {
                return Entity.LastName;
            }
            set
            {
                if (Entity.LastName != value)
                {
                    Entity.LastName = value;
                    this.IsDirty = true;
                }
            }
        }

        public override DateTime CreatedDate
        {
            get
            {
                return Entity.CreatedDate;
            }
            set
            {
                if (Entity.CreatedDate != value)
                {
                    Entity.CreatedDate = value;
                    this.IsDirty = true;
                }
            }
        }

        public override DateTime UpdatedDate
        {
            get
            {
                return Entity.UpdatedDate;
            }
            set
            {
                if (Entity.UpdatedDate != value)
                {
                    Entity.UpdatedDate = value;
                    this.IsDirty = true;
                }
            }
        }

        public override Int32 CreatedByUserId
        {
            get
            {
                return Entity.CreatedByUserId;
            }
            set
            {
                if (Entity.CreatedByUserId != value)
                {
                    Entity.CreatedByUserId = value;
                    this.IsDirty = true;
                }
            }
        }

        public override Int32 UpdatedByUserId
        {
            get
            {
                return Entity.UpdatedByUserId;
            }
            set
            {
                if (Entity.UpdatedByUserId != value)
                {
                    Entity.UpdatedByUserId = value;
                    this.IsDirty = true;
                }
            }
        }

        public String UserName
        {
            get
            {
                return Entity.Username;
            }
            set
            {
                if (Entity.Username != value)
                {
                    Entity.Username = value;
                    this.IsDirty = true;
                }
            }
        }
    }
}